package com.example.mypigcar.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.mypigcar.common.core.SR;
import com.example.mypigcar.utils.WeatherUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.http.util.EntityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zkw
 * @Description TODO
 * @createTime 2021年07月05日 09:42:00
 */
@Api(value="各种接口",tags={"各种接口"})
@RequestMapping("api")
@RestController
public class ApiController {

    @ApiOperation("查询天气")
    @GetMapping("weather")
    public SR getWeather(HttpServletRequest request){
        System.out.println("使用静态默认IP地址：36.248.247.250");
        JSONObject weather = WeatherUtils.getWeather("36.248.247.250");
        return SR.ok().data(weather);
    }


}
